package flc.ast.adapter;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyPassKindBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class CumulativePasswordAdapter extends StkProviderMultiAdapter<MyPassKindBean> {

    public CumulativePasswordAdapter() {
        addItemProvider(new StkSingleSpanProvider(30));
        addItemProvider(new CumulativePasswordProvider());
    }

    private class CumulativePasswordProvider extends BaseItemProvider<MyPassKindBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_cumulative_password;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyPassKindBean bean) {
            baseViewHolder.setImageResource(R.id.ivCumulativePasswordItemImg, bean.getImg());
            baseViewHolder.setText(R.id.tvCumulativePasswordItemName, bean.getKind());
            if (bean.getList() != null && bean.getList().size() > 0) {
                baseViewHolder.setText(R.id.tvCumulativePasswordItemCount, bean.getList().size() + "");
            } else {
                baseViewHolder.setText(R.id.tvCumulativePasswordItemCount, 0 + "");
            }
        }
    }
}
